package org.price.sql.repo.documents.config;

import java.sql.Connection;

import org.apache.log4j.Logger;

public abstract class SQLThread extends Thread {
    private static final Logger LOG = Logger.getLogger(SQLThread.class);

    private Connection connection;

    public SQLThread(Connection connection) {
        setConnection(connection);
    }

    protected abstract void executeQuery() throws Exception;

    @Override
    public void run() {
        try {
            executeQuery();
        } catch (Exception e) {
            LOG.error("Error executing query.", e);
        }
    }

    public void setConnection(Connection connection) {
        this.connection = connection;
    }

    public Connection getConnection() {
        return connection;
    }
}
